﻿CREATE PROCEDURE [dbo].[Person_Insert]

@CreatedBy uniqueidentifier
, @ModifiedBy uniqueidentifier
, @GenderID uniqueidentifier
, @RaceID uniqueidentifier
, @ResidentialAddressID uniqueidentifier
, @ContactDetailID uniqueidentifier
, @IdentityTypeID uniqueidentifier
, @FirstName varchar (24)
, @MiddleName varchar (24)
, @Surname varchar (24)
, @Initials varchar (6)
, @IdentityNumber varchar (24)
, @DateOfBirth datetime
, @Age int
AS
BEGIN
SET NOCOUNT ON

DECLARE @CreatedDate datetime
DECLARE @ModifiedDate datetime
DECLARE @Deleted bit
DECLARE @PersonID uniqueidentifier
SET @CreatedDate = GETDATE()
SET @ModifiedDate = GETDATE()
SET @Deleted = 0
SET @PersonID = NEWID()

INSERT INTO [dbo].[Person] ([PersonID]
, [CreatedDate]
, [CreatedBy]
, [ModifiedDate]
, [ModifiedBy]
, [Deleted]
, [GenderID]
, [RaceID]
, [ResidentialAddressID]
, [ContactDetailID]
, [IdentityTypeID]
, [FirstName]
, [MiddleName]
, [Surname]
, [Initials]
, [IdentityNumber]
, [DateOfBirth]
, [Age]
)
VALUES (@PersonID
, @CreatedDate
, @CreatedBy
, @ModifiedDate
, @ModifiedBy
, @Deleted
, @GenderID
, @RaceID
, @ResidentialAddressID
, @ContactDetailID
, @IdentityTypeID
, @FirstName
, @MiddleName
, @Surname
, @Initials
, @IdentityNumber
, @DateOfBirth
, @Age
)

SELECT @PersonID [PersonID]
END
